/**
 * 音乐相关 Mock 接口
 */

import Mock from 'mockjs'
import type { MockConfig } from '../server'

const musicMocks: MockConfig[] = [
  // 获取流行音乐列表
  {
    url: '/api/popular/list',
    method: 'GET',
    response: () => {
      return {
        code: 200,
        msg: '获取成功',
        data: Mock.mock({
          'list|10-20': [{
            'id|+1': 1,
            name: '@ctitle(2, 6)',
            artist: '@cname',
            album: '@ctitle(3, 8)',
            duration: '@integer(180, 300)',
            coverUrl: "@image('200x200', '@color', '#FFF', 'Album')",
            playUrl: 'https://music.example.com/play/@integer(1000, 9999).mp3',
            'playCount|1000-1000000': 1,
            'likeCount|100-10000': 1,
            releaseDate: '@date("yyyy-MM-dd")'
          }]
        }).list
      }
    }
  },

  // 获取推荐歌单
  {
    url: '/api/playlist/recommend',
    method: 'GET',
    response: () => {
      return {
        code: 200,
        msg: '获取成功',
        data: Mock.mock({
          'list|8-12': [{
            'id|+1': 1,
            name: '@ctitle(4, 10)',
            description: '@csentence(10, 30)',
            coverUrl: "@image('300x300', '@color', '#FFF', 'Playlist')",
            'playCount|10000-1000000': 1,
            'trackCount|20-100': 1,
            creator: {
              id: '@integer(1, 1000)',
              nickname: '@cname',
              avatar: "@image('50x50', '@color', '#FFF', 'User')"
            },
            tags: Mock.mock({
              'list|1-3': ['流行', '摇滚', '民谣', '电子', '古典', '爵士', 'R&B', '说唱']
            }).list,
            createTime: '@datetime("yyyy-MM-dd HH:mm:ss")'
          }]
        }).list
      }
    }
  },

  // 获取歌曲详情
  {
    url: /\/api\/song\/(\d+)/,
    method: 'GET',
    response: (options: any) => {
      const id = options.url.match(/\/api\/song\/(\d+)/)[1]
      return {
        code: 200,
        msg: '获取成功',
        data: Mock.mock({
          id: +id,
          name: '@ctitle(2, 6)',
          artist: '@cname',
          album: '@ctitle(3, 8)',
          duration: '@integer(180, 300)',
          coverUrl: "@image('400x400', '@color', '#FFF', 'Song')",
          playUrl: `https://music.example.com/play/${id}.mp3`,
          'playCount|1000-1000000': 1,
          'likeCount|100-10000': 1,
          releaseDate: '@date("yyyy-MM-dd")',
          lyrics: '@cparagraph(20, 50)',
          genre: '@pick(["流行", "摇滚", "民谣", "电子", "古典", "爵士"])',
          'quality|1': ['128k', '320k', 'flac', 'hi-res']
        })
      }
    }
  },

  // 获取轮播图
  {
    url: '/api/banner/list',
    method: 'GET',
    response: () => {
      return {
        code: 200,
        msg: '获取成功',
        data: Mock.mock({
          'list|3-6': [{
            'id|+1': 1,
            title: '@ctitle(4, 12)',
            imageUrl: "@image('800x300', '@color', '#FFF', 'Banner')",
            linkUrl: '/playlist/@integer(1, 100)',
            'type|1': ['playlist', 'album', 'artist', 'activity'],
            'order|+1': 1
          }]
        }).list
      }
    }
  }
]

export default musicMocks